﻿var count = 0;
function getNews(sel){
	count = sel;	
	//count = -1;	
	getNewsContent(sel);
	getPagging(sel);
}
function getPagging(sel){
	var max_ = listNews.length;
	var html = '';
	for(var i=0;i<max_;i++){
		if(i == sel){
			html += '<span href="" class="sel">'+(i+1)+'</span>';
		}else{
			html += '<a href="javascript:getNews('+i+');">'+(i+1)+'</a>';
		}		
	}	
	$('#paggging').html(html);
}
function getNewsContent(sel){	
	$('#newsContent').html(listNews[sel]);
}
$(document).ready(function () {
	//loopNews();
	loadBanner();
});
function loopNews(){
	if(count == -1)
	 	return false;
	var max_ = listNews.length;
	if(count > max_ - 1){
		count = 0;
	}
	getNewsContent(count);
	getPagging(count);
	count++;
	setTimeout("loopNews();",timeout);
}
var index_curent = 0;
function loadBanner(){
	var max_ = listBG.length;
	if(max_ > 1){
		index_curent = (Math.floor ( Math.random ( ) * listBG.length) );
	}
	var bg_img = IMG_URL+'/theme/default/images/'+listBG[index_curent];
    $('#bannderAdv').css('background-image','url('+bg_img+')');
}
$("#bannderAdv").click( function() {
	////////////////////////////								 
	pageTracker._trackPageview('/trackbanner/index.'+index_curent+'.html');
	///////////
	window.open(link_BG[index_curent],'mywindow');
} );

